//
//  HNSH_AddressEditChooseCell.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/26.
//

#import "HNSH_AddressEditChooseCell.h"

@interface HNSH_AddressEditChooseCell ()

/**  */
@property (nonatomic, strong)UILabel * titleLabel;
/**  */
@property (nonatomic, strong)UILabel * desLabel;
/**  */
@property (nonatomic, strong)UIImageView * rightImgView;
/**  */
@property (nonatomic, strong)UIView * segView;

@end

@implementation HNSH_AddressEditChooseCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor appWhiteLabelColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self configUI];
    }
    return self;
}

- (void)configUI {
    [self addAllViews];
    [self addAllLayout];
}


//MARK: Myself Methods
- (void)addAllViews{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.desLabel];
    [self.contentView addSubview:self.rightImgView];
    [self.contentView addSubview:self.segView];
}

- (void)addAllLayout{
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.height.mas_equalTo(self.contentView);
    }];
    [self.rightImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.width.height.mas_equalTo(20);
        make.centerY.mas_equalTo(self.contentView);
    }];
    [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.rightImgView.mas_left).offset(-5);
        make.top.height.mas_equalTo(self.contentView);
    }];
    [self.segView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(0.5);
    }];
}

//MARK: Setter Methods
- (void)setDic:(NSDictionary *)dic{
    _dic = dic;
    
    self.titleLabel.text = dic[@"title"];
    NSString * con = dic[@"con"];
    NSString * place = dic[@"place"];
    if ([con isNotBlank]) {
        self.desLabel.textColor = [UIColor appBlack333LabelColor];
        self.desLabel.text = con;
    } else {
        self.desLabel.textColor = [UIColor colorWithHexString:@"#999999"];
        self.desLabel.text = place;
    }
}

//MARK: Getter Methods
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.textColor = [UIColor appBlack333LabelColor];
    }
    return _titleLabel;
}

- (UILabel *)desLabel{
    if (!_desLabel) {
        _desLabel = [UILabel new];
        _desLabel.font = [UIFont systemFontOfSize:16];
        _desLabel.textColor = [UIColor appBlack333LabelColor];
        _desLabel.textAlignment = NSTextAlignmentRight;
    }
    return _desLabel;
}

- (UIImageView *)rightImgView{
    if (!_rightImgView) {
        _rightImgView = [UIImageView new];
        _rightImgView.image = [UIImage imageNamed:@"base_right"];
    }
    return _rightImgView;
}

- (UIView *)segView{
    if (!_segView) {
        _segView = [UIView new];
        _segView.backgroundColor = [UIColor colorWithHexString:@"#CCCCCC"];
    }
    return _segView;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
